/**
 * 
 */
package za.co.sindi.oauth.core.scanner.filter.impl;

import za.co.sindi.oauth.core.scanner.filter.TypeFilter;

/**
 * @author Buhake Sindi
 * @since 14 April 2012
 *
 */
public class PatternMatchingTypeFilter implements TypeFilter {

	private final String pattern;
	
	/**
	 * @param pattern
	 */
	public PatternMatchingTypeFilter(final String pattern) {
		super();
		if (pattern == null) {
			throw new IllegalArgumentException("A pattern may not be null.");
		}
		
		this.pattern = pattern;
	}

	/* (non-Javadoc)
	 * @see com.neurologic.oauth.core.scanner.filter.TypeFilter#match(java.lang.Class)
	 */
	@Override
	public boolean match(Class<?> clazz) {
		// TODO Auto-generated method stub
		if (clazz == null) {
			throw new IllegalArgumentException("No class type provided.");
		}
		
		return clazz.getName().matches(pattern);
	}
}
